package org.example.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.example.project.common.convention.result.Result;
import org.example.project.common.convention.result.Results;
import org.example.project.dto.req.DeleteRecycleBinReqDTO;
import org.example.project.dto.req.MoveToRecycleBinReqDTO;
import org.example.project.dto.req.RecoverRecycleBinReqDTO;
import org.example.project.dto.req.ShortLinkRecycleBinPageReqDTO;
import org.example.project.dto.resp.ShortLinkPageRespDTO;
import org.example.project.service.RecycleBinService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 回收站控制器
 *
 * @author weibin
 * @since 2025/10/13 21:29
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/recycle-bin")
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    @PostMapping("/moveTo")
    public Result<Void> moveTo(@RequestBody MoveToRecycleBinReqDTO requestParam) {
        recycleBinService.moveTo(requestParam);
        return Results.success();
    }

    @PostMapping("/pageShortLink")
    public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(@RequestBody ShortLinkRecycleBinPageReqDTO requestParam) {
        return Results.success(recycleBinService.pageShortLink(requestParam));
    }

    @PostMapping("/recover")
    public Result<Void> recover(@RequestBody RecoverRecycleBinReqDTO requestParam) {
        recycleBinService.recover(requestParam);
        return Results.success();
    }

    @PostMapping("/delete")
    public Result<Void> delete(@RequestBody DeleteRecycleBinReqDTO requestParam) {
        recycleBinService.delete(requestParam);
        return Results.success();
    }


}
